#ifndef SERIAL_PORT_H
#define SERIAL_PORT_H

#include <string>

class SerialPort {
public:
    SerialPort();
    ~SerialPort();
    
    int openPort(const std::string& portName, int baudRate);
    
    void closePort();
    
    ssize_t writeData(const char* data, size_t length);

    // 读取数据
    ssize_t readData(char* buffer, size_t bufferSize, int timeout_ms);

private:
    int fd_ = -1; // 文件描述符
    std::string port_name_;
};

#endif // SERIAL_PORT_H